<?php

class HomeController extends Controller
{
	public $layout='//layouts/home';
	
	public function actionIndex()
	{
		// renders the view file 'protected/views/site/index.php'
		// using the default layout 'protected/views/layouts/main.php'
		//HOme info
		$criteria = new CDbCriteria();
		$criteria->select='*';  // only select the 'title' column
		$criteria->condition='code=:code';
		$criteria->params = array(":code"=>'INTRO');
		$content = Page::model()->find($criteria);
		
		$criteria = new CDbCriteria();
		$criteria->select='*';
		$youtubes = Video::model()->findAll();
		
		$this->pageDesc = $content->content;
		$this->pageTitle = Lang::getResource("home.title");
		
		$this->render('index', array("page_content"=>$content,
				"youtubes"=>$youtubes
				));
	}
	
	
	public function actionCateCarousel(){
		//PRODUCT INFO
		$criteria = new CDbCriteria;
		$criteria->limit = 10;
		$products=Category::model()->findAll($criteria);
		$dataProvider = new CArrayDataProvider($products, array(
				'id'=>'Category',
				'pagination'=>array(
						'pageSize'=>10,
				),
		));
		
		$this->renderPartial('_carousel', array(
				'prodProvider'=>$dataProvider));
		
	}
	
	public function actionHomePost(){
		$criteria = new CDbCriteria;
		$criteria->limit = 5;
		$criteria->order = 'createdDate DESC';		
		$posts=Post::model()->findAll($criteria);
		$this->renderPartial('_postHome', array(
				'posts'=>$posts));
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}